package com.rags.chess.base;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.rags.chess.game.Game;


public abstract class Piece implements Cloneable {
	private static Log log = LogFactory.getLog(Piece.class);
	private Color color;
	private int value;
	private Coordinate position;
	private String notation;

	public Piece(Color aColor, Coordinate aPosition, int aValue, String aNotation) {
		color = aColor;
		value = aValue;
		position = aPosition;
		notation = aNotation;
	}
	
	public abstract boolean isValidMove(Game game, Coordinate destination);
	
	public Coordinate getPosition() {
		return position;
	}
	
	public Color getColor() {
		return color;
	}
	
	public int getValue() {
		return value;
	}
	
	public boolean isWhite() {
		return color.equals(Color.WHITE);
	}
	
	public boolean isBlack() {
		return color.equals(Color.BLACK);
	}

	public void setPosition(Coordinate aPosition) {
		position = aPosition;
	}

	public String getNotation() {
		return notation;
	}
	
	@Override
	public Piece clone() {
		try {
			return (Piece)super.clone();
		} catch(CloneNotSupportedException e) {
			log.error("Error cloning piece, should have never happened!");
			return null;
		}
	}
}
